package com.wcs.spring.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.wcs.spring.entity.School;

/**
 * <p>
 * Title: Phicomm_[子系统统名]_[模块名]
 * </p>
 * <p>
 * Description: [描述该类概要功能介绍]
 * </p>
 * 
 * @author hexuan2014
 * @version $Revision$ 2015-6-23
 * @author (lastest modification by $Author$)
 * @since 1.0
 */
@Repository(value = "schoolMapper")
public interface SchoolMapper {

	@Select(value = "${sql}")
	List<School> querySchoolList(@Param(value = "sql") String sql);

	@Insert("insert into school (schoolName,shortName,address,telNo,mobile,createTime,updateTime,createUser,updateUser,flag) "
			+ "values (#{u.schoolName},#{u.shortName},#{u.address},#{u.telNo},#{u.mobile},#{u.createTime},#{u.updateTime},#{u.createUser},#{u.updateUser},0)")
	int addSchool(@Param("u") School school);

	@Update("UPDATE school SET schoolName=#{u.schoolName}, shortName=#{u.shortName}, address=#{u.address}, "
			+ "telNo=#{u.telNo}, mobile=#{u.mobile}, updateTime=#{u.updateTime}, updateUser=#{u.updateUser} "
			+ " WHERE id=#{u.id}")
	void updateSchool(@Param("u") School school);

	@Update("UPDATE school SET flag=1 WHERE id=#{u.id}")
	void delSchool(@Param("u") School school);

	@Delete("DELETE FROM school WHERE id = #{u.id}")
	void deleteSchool(@Param("u") School school);

	@Select({ "SELECT * FROM School WHERE id = #{id}" })
	School querySchoolById(Integer id);
}
